﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoopInstance : MonoBehaviour
{
    public static LoopInstance Instance;

    public GameObject[] prefabs;

    private Dictionary<string, GameObject> _dictionary = new Dictionary<string, GameObject>();


    private void Awake()
    {
        Instance = this;
        for (int i = 0; i < prefabs.Length; i++)
        {
            _dictionary.Add(prefabs[i].name, prefabs[i]);
        }
    }

    public GameObject NewPanel(string name)
    {
        if (_dictionary.ContainsKey(name))
        {
            return GameObject.Instantiate(_dictionary[name], transform);
        }

        return null;
    }
}